package com.yanq.liancar.net;

import android.content.Context;

import com.yanq.liancar.activity.ApkDialog;
import com.yanq.liancar.bean.BaseBean;
import com.yanq.liancar.net.util.ProgressSubscriber;
import com.yanq.liancar.util.SystemUtil;
import com.yanq.liancar.util.ToastUtil;

public class Net {

    public static void checkVersion(final Context context, final boolean isShow) {
        HttpUtil.getInstance().checkVersion(new ProgressSubscriber<BaseBean>(context) {
            @Override
            public void next(BaseBean baseBean) {
                String data = (String) baseBean.getData();
                if (data != null) {
                    int version = Integer.parseInt(data);
                    if (version > SystemUtil.getVersionCode(context)) {
                        new ApkDialog(context);
                    } else {
                        if (isShow) {
                            ToastUtil.show(context, "当前已是最新版本");
                        }
                    }
                }
            }
        });
    }
}